#!/usr/bin/env python3.0

import collections

class customList(collections.UserList):
	def __init__(self, list=[]):
		collections.UserList.__init__(self, list)
		if len(self.data)==0:
			self.currentpos = -1
		else:
			self.currentpos = 0
	def __adjustPosition(self):
		if self.currentpos >= len(self.data):
			self.currentpos = len(self.data) - 1
		elif self.currentpos==-1 and len(self.data)>0:
			self.currentpos = 0
	def current(self):
		self.__adjustPosition()
		if self.currentpos==-1:
			return None
		return self.data[self.currentpos]
	def next(self):
		self.__adjustPosition()
		pos = self.currentpos + 1
		if pos >= len(self.data):
			return False
		else:
			self.currentpos = pos
			return True
	def prev(self):
		self.__adjustPosition()
		pos = self.currentpos - 1
		if pos < 0:
			return False
		else:
			self.currentpos = pos
			return True


def main():

	il = customList( [10, 20, 30] )
	#il = customList( )
	il.append(20)
	print(il.current())



main()
